package Test;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * @Auther: lizhipeng
 * @Date: 2024-10-08 - 10 - 08 - 11:12
 * @Description: Test
 * @version: 1.0
 */
public class TestTreeMap {
    public static void main(String[] args) {
        //有序集合根据key的值进行排序
        TreeMap<Integer,String> treeMap = new TreeMap<Integer,String>();
        treeMap.put(1,"a");
        treeMap.put(2,"b");
        treeMap.put(-1,"d");
        Set<Map.Entry<Integer,String>> entries = treeMap.entrySet();
        for(Map.Entry<Integer,String> entry : entries){
            System.out.println(entry);
        }

    }
}
